<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>v-for 遍历对象</title>
</head>
<body>
<div id="app">
    <!--问题：如何来获取 key 值-->
    <ul>
        <li>{{ person.name }}</li>
        <li>{{ person.age }}</li>
        <li>{{ person.gender }}</li>
    </ul>

    <!--<div>{{ Object.keys(person) }}</div>-->
    <ul>
        <li>{{Object.keys(person)[0]}}:{{ person.name }}</li>
        <li>{{Object.keys(person)[1]}}:{{ person.age }}</li>
        <li>{{Object.keys(person)[2]}}:{{ person.gender }}</li>
    </ul>

    <ul>
        <li v-for="value in person">{{ value }}</li>
    </ul>

    <ul>
        <li v-for="(value,key) in person">{{ key}}:{{ value }}</li>
    </ul>

    <ul>
        <li v-for="(value,key, index) in person">{{ index }}. {{ key}}:{{ value }}</li>
    </ul>
</div>

<script type="module">
    import {createApp, reactive} from "../../../js/vue.esm-browser.js";

    let app = createApp(
        {
            setup() {
                let person = reactive(
                    {
                        name: "abcque",
                        age: 18,
                        gender: "M"
                    }
                )
                return {
                    person
                }
            }
        }
    );

    app.mount("#app")
</script>
</body>
</html>